/* ---------------------------------- env.js -------------------------------- */
if( !VED.env ) {
   VED.env = (function() {
      var agent = navigator.userAgent.toLowerCase();
      var opera = window.opera;

      var env = {
         ie: eval( '/*@cc_on!@*/false' ),
         opera: ( !!opera && opera.version ),
         webkit: ( agent.indexOf( ' applewebkit/' ) > -1 ),
         air: ( agent.indexOf( ' adobeair/' ) > -1 ),
         mac: ( agent.indexOf( 'macintosh' ) > -1 ),
         quirks: ( document.compatMode == 'BackCompat' ),
         mobile: ( agent.indexOf( 'mobile' ) > -1 ),
         iOS: /(ipad|iphone|ipod)/.test( agent ),
         isCustomDomain: function() {
            if ( !this.ie )
               return false;

            var domain = document.domain,
               hostname = window.location.hostname;

            return domain != hostname && domain != ( '[' + hostname + ']' ); // IPv6 IP support (#5434)
         },

         secure: location.protocol == 'https:'
      };

      env.gecko = ( navigator.product == 'Gecko' && !env.webkit && !env.opera );

      if( env.webkit ) {
         if( agent.indexOf( 'chrome' ) > -1 )
            env.chrome = true;
         else
            env.safari = true;
      }

      var version = 0;

      // Internet Explorer 6.0+
      if ( env.ie ) {
         // We use env.version for feature detection, so set it properly.
         if ( env.quirks || !document.documentMode )
            version = parseFloat( agent.match( /msie (\d+)/ )[ 1 ] );
         else
            version = document.documentMode;

         // Deprecated features available just for backwards compatibility.
         env.ie9Compat = version == 9;
         env.ie8Compat = version == 8;
         env.ie7Compat = version == 7;
         env.ie6Compat = version < 7 || env.quirks;
      }

      // Gecko.
      if ( env.gecko ) {
         var geckoRelease = agent.match( /rv:([\d\.]+)/ );
         if ( geckoRelease ) {
            geckoRelease = geckoRelease[ 1 ].split( '.' );
            version = geckoRelease[ 0 ] * 10000 + ( geckoRelease[ 1 ] || 0 ) * 100 + ( geckoRelease[ 2 ] || 0 ) * 1;
         }
      }

      // Opera 9.50+
      if ( env.opera )
         version = parseFloat( opera.version() );

      // Adobe AIR 1.0+
      // Checked before Safari because AIR have the WebKit rich text editor
      // features from Safari 3.0.4, but the version reported is 420.
      if ( env.air )
         version = parseFloat( agent.match( / adobeair\/(\d+)/ )[ 1 ] );

      // WebKit 522+ (Safari 3+)
      if ( env.webkit )
         version = parseFloat( agent.match( / applewebkit\/(\d+)/ )[ 1 ] );

      env.version = version;

      env.isCompatible =
         // White list of mobile devices that VED supports.
         env.iOS && version >= 534 ||
         !env.mobile && (
            ( env.ie && version > 6 ) ||
            ( env.gecko && version >= 10801 ) ||
            ( env.opera && version >= 9.5 ) ||
            ( env.air && version >= 1 ) ||
            ( env.webkit && version >= 522 ) ||
            false
         );

      env.hidpi = window.devicePixelRatio >= 2;

      env.cssClass = 'ved_browser_' + ( env.ie ? 'ie' : env.gecko ? 'gecko' : env.opera ? 'opera' : env.webkit ? 'webkit' : 'unknown' );

      if( env.quirks )
         env.cssClass += ' ved_browser_quirks';

      if( env.ie ) {
         env.cssClass += ' ved_browser_ie' + ( env.quirks || env.version < 7 ? '6' : env.version );

         if( env.quirks )
            env.cssClass += ' ved_browser_iequirks';
      }

      if( env.gecko ) {
         if( version < 10900 )
            env.cssClass += ' ved_browser_gecko18';
         else if( version <= 11000 )
            env.cssClass += ' ved_browser_gecko19';
      }

      if( env.air )
         env.cssClass += ' ved_browser_air';

      if ( env.iOS )
         env.cssClass += ' ved_browser_ios';

      if ( env.hidpi )
         env.cssClass += ' ved_hidpi';

      return env;
   })();
}




